using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Logger;

namespace FiltronASP.Models.DAO.Filtron
{
    public class FiltronLogisticsInfoDAO : Abstracts.AbstractGenericDAO<FiltronLogisticsInfo, System.Nullable<int>>,
        Interfaces.Filtron.IFiltronLogisticsInfoDAO
    {
        /// <summary>
        /// Metoda zwracajaca nazwe parametru bedacego kluczem glownym tabeli.
        /// </summary>
        /// <returns>nazwa klucza glownego</returns>
        protected override string GetKeyProperty()
        {
            return "logistics_info_id";
        }

        public IQueryable<FiltronLogisticsInfo> FindByFilterId(int filterId)
        {
            if (filterId.Equals(0))
            {
                return null;
            }   //if
            try
            {
                IQueryable<FiltronLogisticsInfo> info = this._cmsEntitiesDataContext.FiltronLogisticsInfos.Where(
                    l => l.filter_id.Equals(filterId)
                        );
                if (!(info.Any()))
                {
                    return null;
                }   //if
                return info;
            }   //try
            catch (Exception ex)
            {
                MyLogger.Log(ex);
            }   //catch
            return null;
        }

    }
}
